<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://www.centit.com/el/coderepo" prefix="cp"%>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018-7-6
  Time: 19:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        h1 {color: red; display : inline;font-size: 14px}
        .t {
            font-weight: 400;
            font-size: medium;
            margin-bottom: 1px;
        }
    </style>
</head>
<body>
<div>
    <div id="content_left">
        <div class="nums"><span class="nums_text">为您找到相关结果约${returnResult.key}个</span></div>
        <div id="contentSearch">
            <c:forEach items="${returnResult.value}" var="info" varStatus="varStatus">
                <div class="result c-container " id="${varStatus.count}">
                <c:choose>
                    <c:when test="${info._type eq 'file'}">
                        <h3 class="t"><a href="${info.optUrl}">${varStatus.count}.${info.fileName}</a></h3>
                    </c:when>
                    <c:otherwise>
                        <h3 class="t"><a href="${info.optUrl}">${varStatus.count}.${info.title}</a></h3>
                    </c:otherwise>
                </c:choose>
                   <div>${info.highlight}...</div>
                    <br><div style="text-align: right">${info.createTime}</div></div>
            </c:forEach>

        </div>
        <div id="pageCount"></div>
    </div>
   <%-- <div id="content_right">
        右边内容

    </div>--%>
</div>
</body>
<script>
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;
        //总页数大于页码总数
        laypage.render({
            elem: 'pageCount'
            ,count:"${returnResult.key}" //数据总数
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj, first){
                var htmltable="";
                     //obj包含了当前分页的所有参数，比如：
                    //首次不执行
                   if(!first){
                        //do something
                var searchContent=$("#searchContent").val();
               // searchContent=escape (encodeURIComponent(searchContent));
                       $.ajax({
                           type: 'get',
                           url: "${cp:SYS_VALUE('app.staticfile.home')}/system/search/esSearch/layuisearch",
                           data: {"queryWord":searchContent,"type":$('.header_search input[name="type"]:checked ').val(),"pageNo":obj.curr,"pageSize":obj.limit},
                           success:function (data) {
                              $("#contentSearch").empty();
                              if("${returnResult.key}">0){
                               layui.each(data.data, function(index,item){
                                   htmltable+=" <div class=\"result c-container \" id=\""+(index+1)+"\">";
                                   if(item._type == 'file'){
                                       htmltable+="<h3 class=\"t\"><a href=\""+item.optUrl+"\">"+(index+1)+"."+item.fileName+"</a></h3>";
                                   }else{
                                       htmltable+="<h3 class=\"t\"><a href=\""+item.optUrl+"\">"+(index+1)+"."+item.title+"</a></h3>";
                               }
                                   htmltable+="<div>"+item.highlight+"...</div>";
                                   htmltable+="<br><div style=\"text-align: right\">"+item.createTime+"</div></div>";
                               });
                              }
                               $("#contentSearch").html(htmltable);
                               closeLoading();
                           },
                           error:function(){
                               alert("执行失败");
                           }
                          
                       });
                   }

            }
        });
    });

    closeLoading();
</script>
</html>
